<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="common/include :: header('商品属性列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <form id="customer-form">
            <input type="hidden" name="goodsId" id="goodsId" th:field="${goods.id}">
        </form>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="business:attr:add">
                <i class="fa fa-plus"></i> 添加
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="common/include :: footer"/>
<script th:inline="javascript">

    var removeFlag = [[${@permission.hasPermi('business:attr:remove')}]];
    var listFlag = [[${@permission.hasPermi('business:attr:list')}]];
    var editFlag = [[${@permission.hasPermi('business:attr:edit')}]];
    var prefix = ctx + "/business/attr";
    $(function () {
        let goodsId = $("#goodsId").val();
        var options = {
            url: prefix + "/query",
            createUrl: prefix + "/addPage?goodsId=" + goodsId,
            updateUrl: prefix + "/editPage?id={id}",
            removeUrl: prefix + "/remove",
            uniqueId: 'id',
            modalName: "属性",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '编号',
                    visible: false
                },
                // {
                //     field: 'goodsName',
                //     title: '商品名称'
                // },
                {
                    field: 'attribute',
                    title: '属性'
                },
                {
                    field: 'content',
                    title: '内容'
                },
                {
                    field: 'sort',
                    title: '顺序'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var editFlagTemp = editFlag;
                        var removeFlagTemp = removeFlag;

                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlagTemp + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push("<a class='btn btn-danger btn-xs " + removeFlagTemp + "' href='javascript:void(0)' onclick='$.operate.remove(" + row.id + ")'><i class='fa fa-remove'></i>删除</a>");
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
    function viewAttr(attrSrc) {
        $("#attrSrc").attr("src", attrSrc);
    }
</script>
</body>
</html>